﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PayforPatient.aspx.cs" Inherits="RegisterWeb.Manager.PatientManager.PayforPatient" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>     
      <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<script type="text/javascript">
		    $(function () {
		        draw();
		        $('#tu').combobox({
		            url: 'ashx/TuJson.ashx',
		            editable: false,
		            valueField: 'val',
		            textField: 'text',
		            onSelect: function draw1() {
		                var cdata = [];
		                var i = 0;
		                var flag = 0;
		                var chart;
		                var cdata1 = [];
		                var xdata = [];
		                var type = document.getElementsByName("type")[0].value;
		                var tu = document.getElementsByName("tu")[0].value;
		                var options = {
		                    chart: {
		                        renderTo: 'container'
		                    },
		                    title: {
		                        text: '用户信息统计'
		                    },
		                    subtitle: {
		                        text: '信息统计'
		                    },
		                    xAxis: {
		                },
		                yAxis: {
		                    min: 0,
		                    title: {
		                        text: 'Nuclear weapon states'
		                    },
		                    labels: {
		                        formatter: function () {
		                            return this.value / 1000 + 'k';
		                        }
		                    }
		                },
		                legend: {
		                    layout: 'vertical',
		                    backgroundColor: '#FFFFFF',
		                    align: 'left',
		                    verticalAlign: 'top',
		                    x: 100,
		                    y: 70,
		                    floating: true,
		                    shadow: true
		                },
		                tooltip: {
		                    formatter: function () {
		                        if (tu == "3") {
		                            return '<b>' + this.point.name + '</b>: ' + this.percentage.toString() + ' %';
		                        }
		                        else
		                            return '' + this.x + ': ' + this.y;
		                    }
		                },
		                plotOptions: {
		                    column: {
		                        pointPadding: 0.2,
		                        borderWidth: 0
		                    }
		                },
		                series: [{
		                    name: '信息'
		                }, { name: '信息222'}]
		            };
		            $.post("ashx/PayforPatientService.ashx", { "action": type }, function (data, textStatus) {
		                if (textStatus == "success") {
		                    dataments = $.parseJSON(data);

		                    var da = new Array();
		                    var total = 0;
		                    if (tu == "3") {
		                        for (i = 0; i < dataments.length; i++) {
		                            total = total + parseFloat(dataments[i].ydata);
		                        }
		                    }
		                    for (i = 0; i < dataments.length; i++) {
		                        if (tu == "3") {
		                            da[i] = new Array();
		                            da[i][0] = dataments[i].xdata;
		                            da[i][1] = parseFloat(dataments[i].ydata) / total;
		                        }
		                        else {
		                            cdata[i] = parseFloat(dataments[i].ydata);
		                            xdata[i] = dataments[i].xdata;
		                        }
		                    }

		                    options.series[0].data = da;
		                    options.series[1].data = da;
		                }
		                else {
		                    alert("AJAX返回错误");
		                }


		                if (tu == "1") {
		                    options.chart.type = 'column';
		                    options.series[0].data = cdata;
		                }
		                else if (tu == "2") {
		                    options.chart.type = 'area';
		                    options.series[0].data = cdata;
		                }
		                else if (tu == "3") {
		                    options.chart.type = 'pie';
		                }
		                options.xAxis.categories = xdata;
		                for (i = 0; i < 1; i++) {
		                    chart = new Highcharts.Chart(options);
		                }
		            });
		        }
		    });
		});

		    function draw() {
		        var cdata = [];
		        var i = 0;
		        var flag = 0;
		        var chart;
		        var cdata1 = [];
		        var xdata = [];
		        var type = document.getElementsByName("type")[0].value;
		        var tu = document.getElementsByName("tu")[0].value;
		        var options = {
		            chart: {
		                renderTo: 'container'
		            },
		            title: {
		                text: '用户信息统计'
		            },
		            subtitle: {
		                text: '信息统计'
		            },
		            xAxis: {
		        },
		        yAxis: {
		            min: 0,
		            title: {
		                text: 'Nuclear weapon states'
		            },
		            labels: {
		                formatter: function () {
		                    return this.value / 1000 + 'k';
		                }
		            }
		        },
		        legend: {
		            layout: 'vertical',
		            backgroundColor: '#FFFFFF',
		            align: 'left',
		            verticalAlign: 'top',
		            x: 100,
		            y: 70,
		            floating: true,
		            shadow: true
		        },
		        tooltip: {
		            formatter: function () {
		                if (tu == "3") {
		                    return '<b>' + this.point.name + '</b>: ' + this.percentage.toString() + ' %';
		                }
		                else
		                    return '' + this.x + ': ' + this.y;
		            }
		        },
		        plotOptions: {
		            column: {
		                pointPadding: 0.2,
		                borderWidth: 0
		            }
		        },
		        series: [{
		            name: '信息'
		        }]
		    };
		    $.post("ashx/PayforPatientService.ashx", { "action": type }, function (data, textStatus) {
		        if (textStatus == "success") {
		            dataments = $.parseJSON(data);

		            var da = new Array();
		            var total = 0;
		            if (tu == "3") {
		                for (i = 0; i < dataments.length; i++) {
		                    total = total + parseFloat(dataments[i].ydata);
		                }
		            }
		            for (i = 0; i < dataments.length; i++) {
		                if (tu == "3") {
		                    da[i] = new Array();
		                    da[i][0] = dataments[i].xdata;
		                    da[i][1] = parseFloat(dataments[i].ydata) / total;
		                }
		                else {
		                    cdata[i] = parseFloat(dataments[i].ydata);
		                    xdata[i] = dataments[i].xdata;
		                }
		            }

		            options.series[0].data = da;
		        }
		        else {
		            alert("AJAX返回错误");
		        }


		        if (tu == "1") {
		            options.chart.type = 'column';
                    options.series[0].data = cdata;
		        }
		        else if (tu == "2") {
		            options.chart.type = 'area';
                    options.series[0].data = cdata;
		        }
		        else if (tu == "3") {
		            options.chart.type = 'pie';
		        }
		        options.xAxis.categories = xdata;
		        for (i = 0; i < 1; i++) {
		            chart = new Highcharts.Chart(options);
		        }
		    });
		}
		</script>
</head>
<body>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>


<form id="form1" runat="server">

<div  class="easyui-panel" title="用户统计" style="width:auto;height:550px" collapsible="true"
    >
    查询类型:
           <select  id="type" name="type"   class="easyui-combobox"   panelHeight="auto" style="width:100px;"  required="true">  
                 <option value="1">用户等级</option>
                 <option  value="2">挂号履行率</option>
                 </select>         
    显示类型:
           <select id="tu" name="tu"  class="easyui-combobox"  panelHeight="auto" style="width:70px;">
                    <option value="1">柱形图</option>
                    <option  value="2">折线图</option>
                    <option   value="3">饼形图</option>
                </select>
                <a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="draw()">查询</a>
                                                         
  <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
    </div>
    </div>
    </form>
</body>
</html>
